package com.xxx.test;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import com.xxx.DAO.user_bookDao;

@WebServlet("/borrowed")
public class borrowed extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String userId= request.getSession().getAttribute("id").toString();
        String bName = new String(request.getParameter("bName").getBytes("iso-8859-1"), "UTF-8");
        int result=0;
        user_bookDao dao=new user_bookDao();
        result=dao.isBorrowed(userId,bName);
        request.setAttribute("result",result);
        request.getRequestDispatcher("Catalog.jsp").forward(request, response);
    }
}
